<?php
class FooterEditForm extends Form{
	function FooterEditForm(){
		Form::Form('FooterEditForm');
		AZLib::get_config();
	}
	
	function on_submit(){
		$footerContent		=	Url::get('content');
		
		if(get_magic_quotes_gpc()){
			$footerContent  	= stripslashes($footerContent);
		}
		
		require_once ROOT_PATH.'includes/htmLawed.php';
		
		$config = array(
			'safe'=>1, // Dangerous elements and attributes thus not allowed
			'elements'=>'*', // All except table-related are OK
			'deny_attribute'=>'class, id' // None of the allowed elements can have these attributes
		);
		
		$spec = 'a = title, href;'; // The 'a' element can have only these attributes

		$footerContent = htmLawed($footerContent, $config, $spec);
		$footerContent = AZLib::clean_value($footerContent);
		
		$this->checkFormInput('Nội dung','content',$footerContent,'str',true);
		
		if(!$this->errNum)
		{
			if(isset(CGlobal::$configs['footer_content']))
				DB::update('configs',array("conf_val"=>$footerContent),"conf_key='footer_content'");
			else
				DB::insert('configs',array("conf_key"=>'footer_content',"conf_val"=>$footerContent));
			
			AZLib::get_config(0,1);
			AZLib::refreshParent();
		}
	}
	
	function draw(){
		global $display;
			
		$footerContent	=	stripslashes(Url::get('content'));
		
		if(!$footerContent){
			$footerContent = stripslashes(@CGlobal::$configs['footer_content']['conf_val']);
			
			if(!$footerContent){
				$footerContent=addslashes(FOOTER_CONTENT);
			}
		}
		
		$display->add("msg",$this->showFormErrorMessages(1));
		
		$display->add("content",$footerContent);
		
		$this->beginForm();
		$display->output("FooterEdit");
		$this->endForm();
	}
}
?>